package com.yy.micro.magic.core.provider.impl;

import com.yy.micro.magic.core.provider.ResourceProvider;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public abstract class AbstractResourceProvider<T> implements ResourceProvider<T> {

    protected Map<String,T> resources = new ConcurrentHashMap<>(16);

    @Override
    public void regist(String code,final T entity) {
        if (!resources.containsKey(code)){
            resources.put(code,entity);
        }
    }

    @Override
    public T find(final String code) {
        return resources.get(code);
    }
}
